package mo.leetcode_top;

public class L926 {

    public int minFlipsMonoIncr(String s) {
        int dp0 = 0;
        int dp1 = 0;
        for (char c : s.toCharArray()) {
            int curDp0 = dp0 + (c == '0' ? 0 : 1);
            int curDp1 = Math.min(dp0, dp1 + (c == '1' ? 0 : 1));
            dp0 = curDp0;
            dp1 = curDp1;
        }
        return Math.min(dp0, dp1);
    }

}
